import { IFeidaoAiBrowserComponent } from '@feidao/web/interfaces';
import nodejs from '@feidao/web/atom/browser/msg/nodejs';
import render from '@feidao/web/atom/browser/render/render';


import name2title from './fields';
import { Params } from '../atom/params2query';
import p2q from '../atom/params2query';
import generate_query4render from '../atom/generate-query4render';
import generate_sort_fields from '../atom/generate-sort-fields';

import P02 from './P02';
import P04 from './P04';
import P13 from './P13';

export default async function a013(fd: IFeidaoAiBrowserComponent, ...args: any[]) {
	//b 刷新组件
	let page_no = fd.data.params['page_no'];
	if (!page_no) {
		page_no = 1;
	}
	let page_size = fd.data.params['page_size'];
	if (!page_size) {
		page_size = 20;
	}
	const q = p2q(fd.data.params as Params);
	const query = {
		criteria: q.criteria,
		sort: q.sort,
		page_no,
		page_size
	};
	const res = await nodejs(fd.data.spaceid, "teach_staff_find", query);
	if (res.dataArray.length == 0) {
		render(fd, res.dataArray, P04, 'P02', 'inner');
	} else {
		render(fd, res.dataArray, P02, 'P02', 'inner');
	}
	res['page_size'] = page_size;
	render(fd, res, P13, 'P13', 'inner');
}
